package com.aipartner.service;

import com.aipartner.common.PageResult;
import com.aipartner.entity.ChatHistory;
import com.baomidou.mybatisplus.extension.service.IService;

/**
 * Chat History Service Interface
 * 
 * @author AI Partner Team
 * @since 2024-01-20
 */
public interface ChatHistoryService extends IService<ChatHistory> {
    
    /**
     * Save chat history
     * 
     * @param userId User ID
     * @param userMessage User message
     * @param aiReply AI reply
     * @param modelType Model type
     * @param tokenUsage Token usage
     * @return Chat history record
     */
    ChatHistory saveChatHistory(Long userId, String userMessage, String aiReply, 
                               String modelType, Integer tokenUsage);
    
    /**
     * Get user chat history with pagination
     * 
     * @param userId User ID
     * @param page Page number
     * @param size Page size
     * @param sessionId Session ID (optional)
     * @param modelName Model name (optional)
     * @return Paginated chat history
     */
    PageResult<ChatHistory> getUserChatHistory(Long userId, Integer page, Integer size, String sessionId, String modelName);
    
    /**
     * Get conversation chat history
     * 
     * @param conversationId Conversation ID
     * @param current Current page
     * @param size Page size
     * @return Conversation chat history
     */
    PageResult<ChatHistory> getConversationHistory(String conversationId, Long current, Long size);
    
    /**
     * Get session chat history
     * 
     * @param sessionId Session ID
     * @param userId User ID
     * @param page Page number
     * @param size Page size
     * @return Session chat history
     */
    PageResult<ChatHistory> getSessionHistory(String sessionId, Long userId, Integer page, Integer size);
    
    /**
     * Delete chat history by ID
     * 
     * @param id History ID
     * @param userId User ID
     * @return Whether deletion was successful
     */
    boolean deleteChatHistory(Long id, Long userId);
    
    /**
     * Clear all chat history for user
     * 
     * @param userId User ID
     * @return Whether clearing was successful
     */
    boolean clearUserChatHistory(Long userId);
}